package corejava2;

import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Queue;

public class TestPriorityQueue {
    //PQ  heap
    public static void main(String[] args) {
        //Queue<Integer> Q = new PriorityQueue<>();//小顶堆
        // Queue<Integer> Q=new LinkedList<>();
        Queue<Integer> Q = new PriorityQueue<>(new Comparator<Integer>() {
            @Override
            public int compare(Integer o1, Integer o2) {
                return o2 - o1;
            }
        });
        int[] a = {1, 3, 5, 7, 9, 2, 4, 6, 8, 0};

        for (int i : a) {
            Q.offer(i);
        }
        while (!Q.isEmpty()) {
            System.out.println(Q.peek());
            Q.poll();
        }
    }
}
